﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TSTreeThesis.Utilities
{
   public class PAATransform
    {
        public double[] Transform(int compressionRate, double[] points)
        {
            int size = points.Length / compressionRate;
            double[] outputPoints = new double[size];

            int max;
            int i;
            int j;
            for (i = 0; i < size; i++)
            {
                outputPoints[i] = 0;

                max = compressionRate * (i + 1);
                for (j = compressionRate * i + 1; j <= max; ++j)
                {
                    outputPoints[i] += points[j - 1];
                }

                outputPoints[i] /= compressionRate;
            }

            return outputPoints;
        }

        public float[] Transform(int compressionRate, float[] points)
        {
            int size = points.Length / compressionRate;
            float[] outputPoints = new float[size];

            int max;
            int i;
            int j;
            for (i = 0; i < size; i++)
            {
                outputPoints[i] = 0;

                max = compressionRate * (i + 1);
                for (j = compressionRate * i + 1; j <= max; ++j)
                {
                    outputPoints[i] += points[j - 1];
                }

                outputPoints[i] /= compressionRate;
            }

            return outputPoints;
        }
    }
}
